<?php
// .-----------------------------------------------------------------------------------
// | WE TRY THE BEST WAY 杭州博也网络科技有限公司
// |-----------------------------------------------------------------------------------
// | Author: 贝贝 <hebiduhebi@163.com>
// | Copyright (c) 2013-2016, http://www.itboye.com. All Rights Reserved.
// |-----------------------------------------------------------------------------------

namespace Shop\Api;
use Common\Api\Api;
use Shop\Model\OrdersExpressModel;

class OrdersExpressApi extends Api{

    /**
     * 查询，不分页
     */
    const QUERY_NO_PAGING = "Shop/OrdersExpress/queryNoPaging";
    /**
     * 添加
     */
    const ADD = "Shop/OrdersExpress/add";
    /**
     * 保存
     */
    const SAVE = "Shop/OrdersExpress/save";
    /**
     * 保存根据ID主键
     */
    const SAVE_BY_ID = "Shop/OrdersExpress/saveByID";

    /**
     * 删除
     */
    const DELETE = "Shop/OrdersExpress/delete";

    /**
     * 查询
     */
    const QUERY = "Shop/OrdersExpress/query";
    /**
     * 查询一条数据
     */
    const GET_INFO = "Shop/OrdersExpress/getInfo";
    /*
     * 连接查询出物流信息和收货地址信息
     * */
    const GET_EXPRESS_CONTACT = "Shop/OrdersExpress/getexpresscontact";

	protected function _init(){
		$this->model = new OrdersExpressModel();
	}

    /*
     * 连表查询得到相应的订单收货信息和物流信息
     * */
    public function getexpresscontact($map = false,$field = false){
        $query = $this->model->where($map);
        if($field === false){
            $result = $query->alias("e")->join('RIGHT JOIN itboye_orders_contactinfo c on e.order_code = c.order_code')->find();
        }else{
            $result = $query->alias("e")->join('RIGHT JOIN itboye_orders_contactinfo c on e.order_code = c.order_code')->field($field)->find();
        }
        if ($result === FALSE) {
            $error = $this->model->getDbError();
            return $this->apiReturnErr($error);
        } else {
            return $this->apiReturnSuc($result);
        }
    }
}
